/* Copyright (C) 2021 Rain */

/* This file is part of XNIX. */

/* 
  XNIX is free software: you can redistribute it and/or modify 
  it under the terms of the GNU General Public License as published by 
  the Free Software Foundation, either version 3 of the License, or 
  (at your option) and later version. 
*/

/*
  XNIX is distributed in the hope that it will be useful, 
  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
  GNU General Public License for more details. 
*/

/*
  You should have received a copy of the GNU General Public License 
   along with XNIX. If not, see <https://www.gnu.org/licenses/>.  
*/




#ifndef _CONSOLE_H
#define _CONSOLE_H


#include <kernel/types.h>
#include <kernel/errno.h>


#define TAB_SIZE  8

errno_t console_init(void);

void putc(char, __uint8_t);
void print(__uint8_t, char *);

int printk(__uint8_t, char *, ...);

void update_cursor(void);
__uint16_t read_cursor(void);

void roll_screen(void);

extern __uint8_t x, y;
extern struct tty tty0;

#define gotoxy(__x, __y) x = (__x);y = (__y);update_cursor();

#define FB_ADDR ((__uint16_t *) 0xb8000)

/* x and y in this vga mode */
#define VGA_X   (bootarg->vga_x)
#define VGA_Y   (bootarg->vga_y)

#define CURSOR_INDEX 	0x03d4
#define CURSOR_DATA 	0x03d5

#define CMD_POS_HI 	0x0e
#define CMD_POS_LO 	0x0f

#define white	0x07
#define red 	0x04
#define yellow 	0x0e

#endif

